package com.ziki.bswicket.component;

import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.model.IModel;

import com.ziki.bswicket.action.ClickAction;
import com.ziki.bswicket.action.SubmitAction;
import com.ziki.framework.wicket.markup.html.form.FwSubmitLink;

public class BsSubmitLink extends FwSubmitLink {
    private static final long serialVersionUID = 1L;
    private ClickAction clickAction;
    private SubmitAction submitAction;

    public BsSubmitLink(String id) {
        super(id);
    }

    public BsSubmitLink(String id, Form<?> form) {
        super(id, form);
    }

    public BsSubmitLink(String id, IModel<?> model) {
        super(id, model);
    }

    public BsSubmitLink(String id, IModel<?> model, Form<?> form) {
        super(id, model, form);
    }

    public void add(ClickAction action) {
        this.clickAction = action;
    }

    public void add(SubmitAction action) {
        this.submitAction = action;
    }

    @Override
    public void onSubmit() {
        if (this.clickAction != null) {
            this.clickAction.performClick();
        }
        if (this.submitAction != null) {
            this.submitAction.performSubmit();
        }
    }

}
